package lance.honeydew.dao;

import lance.honeydew.bean.CategoryBig;
import lance.honeydew.bean.SerialNumber;

import org.apache.log4j.Logger;
import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;


public class SerialNumberDAO extends RootDAO {
	
	private static final Logger logger = Logger.getLogger(SerialNumberDAO.class);
	
	/**
	 * findSerialNumberByTableName
	 * @param tableName
	 * @return
	 */
	public SerialNumber findSerialNumberByTableName(String tableName) {
		
		DetachedCriteria criteria = DetachedCriteria.forClass(SerialNumber.class);
		SerialNumber result = null;
		
		try {
			
			criteria.add(Restrictions.eq(SerialNumber.PROP_TABLENAME, tableName));
			
			result = (SerialNumber) this.getHibernateTemplate().
					findByCriteria(criteria).get(0);
			
		} catch(Exception e) {
			logger.debug(e);
		}
		
		return result;
	}
}